package com.listeningframework.boot.commons.httpclient;

import com.listeningframework.boot.commons.http.HttpMethod;
import com.listeningframework.boot.constants.Encoding;
import org.apache.http.HttpEntity;

/**
 * Http Client Method
 *
 * @author lixining
 * @version $Id: HttpClientMethod.java, v 0.1 2016年8月16日 下午4:29:35 lixining Exp $
 */
public class HttpClientMethod {
    /**
     * 请求地址
     */
    private String address;
    /**
     * 请求参数
     */
    private HttpEntity httpEntity;
    /**
     * 请求方式
     */
    private HttpMethod httpMethod;
    /**
     * 编码方式,默认utf-8
     */
    private Encoding encoding = Encoding.UTF8;
    /**
     * Connect Timeout
     */
    private Integer connectTimeout = 30000;
    /**
     * Socket Timeout
     */
    private Integer socketTimeout = 60000;

    /**
     * Getter method for property <tt>address</tt>.
     *
     * @return property value of address
     */
    public String getAddress() {
        return address;
    }

    /**
     * Setter method for property <tt>address</tt>.
     *
     * @param address value to be assigned to property address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * Getter method for property <tt>httpEntity</tt>.
     *
     * @return property value of httpEntity
     */
    public HttpEntity getHttpEntity() {
        return httpEntity;
    }

    /**
     * Setter method for property <tt>httpEntity</tt>.
     *
     * @param httpEntity value to be assigned to property httpEntity
     */
    public void setHttpEntity(HttpEntity httpEntity) {
        this.httpEntity = httpEntity;
    }

    /**
     * Getter method for property <tt>httpMethod</tt>.
     *
     * @return property value of httpMethod
     */
    public HttpMethod getHttpMethod() {
        return httpMethod;
    }

    /**
     * Setter method for property <tt>httpMethod</tt>.
     *
     * @param httpMethod value to be assigned to property httpMethod
     */
    public void setHttpMethod(HttpMethod httpMethod) {
        this.httpMethod = httpMethod;
    }

    /**
     * Getter method for property <tt>encoding</tt>.
     *
     * @return property value of encoding
     */
    public Encoding getEncoding() {
        return encoding;
    }

    /**
     * Setter method for property <tt>encoding</tt>.
     *
     * @param encoding value to be assigned to property encoding
     */
    public void setEncoding(Encoding encoding) {
        this.encoding = encoding;
    }

    /**
     * Getter method for property <tt>connectTimeout</tt>.
     *
     * @return property value of connectTimeout
     */
    public Integer getConnectTimeout() {
        return connectTimeout;
    }

    /**
     * Setter method for property <tt>connectTimeout</tt>.
     *
     * @param connectTimeout value to be assigned to property connectTimeout
     */
    public void setConnectTimeout(Integer connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    /**
     * Getter method for property <tt>socketTimeout</tt>.
     *
     * @return property value of socketTimeout
     */
    public Integer getSocketTimeout() {
        return socketTimeout;
    }

    /**
     * Setter method for property <tt>socketTimeout</tt>.
     *
     * @param socketTimeout value to be assigned to property socketTimeout
     */
    public void setSocketTimeout(Integer socketTimeout) {
        this.socketTimeout = socketTimeout;
    }

    /**
     * IS Request Get
     *
     * @return boolean
     */
    public boolean isGet() {
        if (httpMethod == null) {
            return false;
        }
        return HttpMethod.GET.name().equals(httpMethod.name());
    }

    /**
     * IS Request Post
     *
     * @return boolean
     */
    public boolean isPost() {
        if (httpMethod == null) {
            return false;
        }
        return HttpMethod.POST.name().equals(httpMethod.name());
    }

}
